package com.kitty.game.fight.ai;

import com.kitty.game.fight.ai.model.RoundSkillUnit;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import com.kitty.game.fight.ai.SkillChooser;


@Getter
@Setter
public class RoundSkillChooser implements SkillChooser {
    private List<RoundSkillUnit> roundSkills = new ArrayList<>();
    private List<Integer> normalSkills = new ArrayList<>();

    @Override
    public void init(List<Integer> skills) {

    }

    @Override
    public int nextSkill(int round) {
        if (roundSkills != null) {
            for (RoundSkillUnit roundSkill : roundSkills) {
                if (round >= roundSkill.getStartRound() && (round - roundSkill.getStartRound()) % roundSkill.getPeriodRound() == 0) {
                    return roundSkill.getSkillId();
                }
            }
        }


        int index = ThreadLocalRandom.current().nextInt(normalSkills.size());
        return normalSkills.get(index);
    }
}
